package domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

/**
 * Pojo user
 * 
 * @author Smouha
 * 
 */
public class User implements Serializable {
	private static final long serialVersionUID = 1L;

	protected long id;
	private String firstName;
	private String lastName;
	private String pseudo;
	private String password;
	private String email;
	private String address;
	private Set<Preference> addressBook = new HashSet<Preference>();

	// private List<User> friendsList = new ArrayList<User>();

	public User() {
		super();
		// TODO Auto-generated constructor stub
	}

	public User(String first_name, String last_name, String pseudo,
			String password) {
		super();
		this.firstName = first_name;
		this.lastName = last_name;
		this.pseudo = pseudo;
		this.password = password;
	}

	/**
	 * Check whether this has a preference with given alias.
	 * 
	 * @param alias
	 *            The alias to check.
	 * @return <tt>true</tt> if this user has a preference with given alias,
	 *         <tt>false</tt> otherwhise.
	 */
	public boolean containsPreference(String alias) {
		for (Preference pref : addressBook) {
			if (pref.getAlias().equalsIgnoreCase(alias)) {
				return true;
			}
		}
		return false;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String first_name) {
		this.firstName = first_name;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String last_name) {
		this.lastName = last_name;
	}

	public String getPseudo() {
		return pseudo;
	}

	public void setPseudo(String pseudo) {
		this.pseudo = pseudo;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Set<Preference> getAddressBook() {
		return addressBook;
	}

	public void setAddressBook(Set<Preference> addressBook) {
		this.addressBook = addressBook;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Override
	public String toString() {
		return "User [id=" + id + ", firstName=" + firstName + ", lastName="
				+ lastName + ", pseudo=" + pseudo + ", password=" + password
				+ ", email=" + email + ", address=" + address
				+ ", addressBook=" + addressBook + "]";
	}

}